<?php
/************************************************************************************************
*   This file is a part of JV-LinkExchanger, a link exchange component for Joomla
*   Copyright (C) 2007-2009  Vijaykumar Niranjan 
*	
*   This program is free software; you can redistribute it and/or modify 
*   it under the terms of the GNU General Public License as published by 
*   the Free Software Foundation; either version 2 of the License, or 
*  (at your option) any later version. 
*
*   This program is distributed in the hope that it will be useful, 
*   but WITHOUT ANY WARRANTY; without even the implied warranty of 
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
*   GNU General Public License for more details. 
*
*   You should have received a copy of the GNU General Public License 
*   along with this program; if not, write to the Free Software 
*   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

* 	JV-LinkExchanger - Link Exchange Component for Joomla 1.0.x
* 	@package JV-LinkExchanger
* 	@file version 1.2.9 RELEASE
* 	@author JV-Extensions
* 	@link http://www.jv-extensions.com
* 	@copyright (C) 2007-2008 by Vijaykumar Niranjan
* 	@license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*  	This program is distributed with the hope that it will be useful,
*  	but WITHOUT ANY WARRANTY; without even the implied warranty of
*  	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
***************************************************************************************************/
#**************************************************************************************************************
// ensure this file is being included by a parent file  
defined('_VALID_MOS') or die('Direct Access to this location is not allowed.'); 
#**************************************************************************************************************
// Default is english.php. Check for others
$JVL = array();
global $JVL;

$lang_file =  $mosConfig_absolute_path."/components/com_jvlinx/lang/user_".$mosConfig_lang.".php";
if (file_exists($lang_file)) 
	include($lang_file);
else
	include($mosConfig_absolute_path."/components/com_jvlinx/lang/user_english.php");	 
#**************************************************************************************************************
// In file admin.mycomp.php 
$mainframe->addCustomHeadTag("<link rel='stylesheet' type='text/css' media='all' href='".$mosConfig_live_site."/components/com_jvlinx/jvlinx.css' title='css file' />");
#**************************************************************************************************************
error_reporting(0);
#**************************************************************************************************************
require_once($mainframe->getPath('front_html')); 
require_once($mainframe->getPath('class')); 
#**************************************************************************************************************
$Itemid = mosGetParam($_REQUEST, 'Itemid', '');
$option = mosGetParam($_REQUEST, 'option', '');
$task = mosGetParam($_REQUEST, 'task', '');
$jv_p = mosGetParam($_REQUEST, 'jv_p', '0');
$jv_v = mosGetParam($_REQUEST, 'jv_v', '0');
$cid = mosGetParam($_REQUEST, 'cid', '0');	
$msg = mosGetParam($_REQUEST, 'mosmsg', '');
$mrc = mosGetParam($_REQUEST, 'mrc', '0');
$pg = mosGetParam($_REQUEST, 'pg', '1');
$emstr = mosGetParam($_REQUEST, 'emstr', '0');
#**************************************************************************************************************
// Init and load configuration
global $database, $JVC, $BANNER_UPLOAD_DIR, $EXT_PATH, $BANNER_UPLOAD_DIR_REL;
#**************************************************************************************************************
$EXT_PATH = "/components/com_jvlinx/banners";
$BANNER_UPLOAD_DIR = $mosConfig_absolute_path.$EXT_PATH;
$BANNER_UPLOAD_DIR_REL = $mosConfig_live_site.$EXT_PATH;
#**************************************************************************************************************
$JVC = array();
$database->setQuery("select * from #__jvlinx_settings");
$database->query();
$JVC = NULL;
$database->loadObject($JVC);
#**************************************************************************************************************
if ($JVC->autoxchange_webid == "")
{
	// Make sure that atleast 1 category exist
	$database->setQuery("select count(id) as CNT from #__jvlinx_categories");
	$database->query();
	$nc = NULL;
	$database->loadObject($nc);
	if (!$nc->CNT)
	{
		echo "<br /><br /><center>".$JVL['A101']."</center><br /><br />";
		return;
	}
}
switch($task) 
{ 
	case "addlink": 		
	{
		HTML_jvlinx::drawPageTitle($JVL['A2']);
		HTML_jvlinx::drawPageSummary($option, $Itemid, "ADDLINK");
		HTML_jvlinx::showNewLinkForm($option, $Itemid);	
		break; 
	}	
	case "adde":		
	{
		HTML_jvlinx::drawPageTitle($JVL['A2']);
		HTML_jvlinx::addLink($option, $Itemid); 
		break;
	}	
	case "addbanner":
	{
		HTML_jvlinx::drawPageTitle($JVL['A95']);
		HTML_jvlinx::drawPageSummary($option, $Itemid, "ADDBANNER");
		HTML_jvlinx::showNewBannerForm($option, $Itemid);	
		break; 
	}
	case "addbe":		
	{
		HTML_jvlinx::drawPageTitle($JVL['A95']);
		HTML_jvlinx::addLink($option, $Itemid); 
		break;
	}	
	case "checklinkstatus":
	{
		HTML_jvlinx::drawPageTitle($JVL['A1']);
		HTML_jvlinx::showCheckLinkStatusForm($option, $Itemid);
		break;
	}
	case "clse":
	{
		HTML_jvlinx::drawPageTitle($JVL['A1']);
		HTML_jvlinx::checkLinkStatus($option, $Itemid);
		break;
	}
	case "recommend":
	{
		HTML_jvlinx::drawPageTitle($JVL['A3']);	
		HTML_jvlinx::showRecommendLinkForm($option, $Itemid);
		break;
	}
	case "rece":
	{
		HTML_jvlinx::drawPageTitle($JVL['A3']);	
		HTML_jvlinx::recommendLink($option, $Itemid);
		break;
	}	
	case "links": 		
	{
		HTML_jvlinx::drawPageTitle($JVL['A83']);	
		HTML_jvlinx::drawPageSummary($option, $Itemid, "DIRECTORY");	

		if ($JVC->enable_search == "yes")
			HTML_jvlinx::drawSearch($option, $Itemid);		

		if ($JVC->enable_ads == "yes")
			HTML_jvlinx::drawAd("TOP");		
		HTML_jvlinx::drawLinks($option, $Itemid, $cid, $pg); 
		break; 		
	}	
	case "autoex": 		
	{
		HTML_jvlinx::drawPageTitle($JVL['A83']);	
		HTML_jvlinx::drawPageSummary($option, $Itemid, "DIRECTORY");	

		if ($JVC->enable_search == "yes")
			HTML_jvlinx::drawSearch($option, $Itemid);		

		if ($JVC->enable_ads == "yes")
			HTML_jvlinx::drawAd("TOP");	
				
		HTML_jvlinx::drawAutoExLinks($option, $Itemid); 
		break; 		
	}	
	case "jsrch":		
	{
		HTML_jvlinx::drawPageTitle($JVL['A6']);	
		HTML_jvlinx::showSearchResults($option, $Itemid); 
		break;	
	}	
	case "rate":		
	{
		HTML_jvlinx::rateLink($option, $Itemid, $jv_p, $jv_v, $cid); 
		break;
	}	
	case "all_links": 		
	{
		HTML_jvlinx::drawPageSummary($option, $Itemid, "DIRECTORY");
	
		if ($JVC->enable_search == "yes")
			HTML_jvlinx::drawSearch($option, $Itemid);		
			
		if ($JVC->enable_ads == "yes")
			HTML_jvlinx::drawAd("TOP");					

		HTML_jvlinx::showAllLinks($option, $Itemid);	
		break; 	
	}	
	case "all_category_links": 		
	{
		HTML_jvlinx::drawPageSummary($option, $Itemid, "DIRECTORY");
		
		if ($JVC->enable_search == "yes")
			HTML_jvlinx::drawSearch($option, $Itemid);		

		if ($JVC->enable_ads == "yes")
			HTML_jvlinx::drawAd("TOP");		
		
		HTML_jvlinx::showAllCatLinks($option, $Itemid, $cid);	
		break; 	
	}	
	case "srem":
	{
		HTML_jvlinx::sendReminder($option, $Itemid);
		break;
	}
	case "emappr":
	{
		HTML_jvlinx::emailApproval($option, $emstr);
		break;
	}
	default: 			
	{
		HTML_jvlinx::drawPageTitle($JVC->fe_title);	
		HTML_jvlinx::drawPageSummary($option, $Itemid, "DIRECTORY");

		if ($JVC->enable_search == "yes")
			HTML_jvlinx::drawSearch($option, $Itemid);				
			
		if ($JVC->enable_ads == "yes")
			HTML_jvlinx::drawAd("TOP");		

		HTML_jvlinx::showHomePage($option, $Itemid); 
		break; 
	}	
} 
	
if ($JVC->enable_ads == "yes")
	HTML_jvlinx::drawAd("BOTTOM");		
	
HTML_jvlinx::drawPageFooter($option, $Itemid);	
#**************************************************************************************************************
?>